#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int m, n;
    int arr1[10][10];
    int arr2[10][10];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &arr1[i][j]);
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &arr2[i][j]);
        }
    }

    int t = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (arr1[i][j] != arr2[i][j])
            {
                t = 1;
                break;
            }
        }
    }
    if (1 == t)
    {
        printf("No");
    }
    else
        printf("Yes");
    return 0;
}